Shader "geometry/geoPointBoom"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _BaseColor("Base Color", Color) = (0, 1, 0, 1)
        _ExtrusionFactor("Extrusion factor", Range(1,50)) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma geometry geom
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float4 normal : NORMAL;
                float2 uv : TEXCOORD0;
            };

            struct v2g
            {
                float4 vertex : SV_POSITION;
                float4 color : COLOR;
                float2 uv : TEXCOORD0;
            };

            struct g2f 
            { 
                float2 uv : TEXCOORD0; 
                float4 vertex : SV_POSITION; 
            }; 

            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed4 _BaseColor;
            float _ExtrusionFactor;

            v2g vert (appdata v)
            {
                v2g o;
                float offset = abs(frac(_Time.y * 0.2)) * _ExtrusionFactor;//_ExtrusionFactor;//
                v.vertex.xyz += normalize(v.normal) * offset;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                return o;
            }

            //以一个三角形为单位进行输入

            [maxvertexcount(1)] 
            void geom(point v2g input[1],inout PointStream<g2f> outStream){ 
                g2f o=(g2f)0; 
                o.vertex = input[0].vertex; 
                o.uv = input[0].uv; 

                outStream.Append(o); 
            } 

            // [maxvertexcount(3)] 
            // void geom(triangle v2g input[3],inout PointStream<g2f> outStream){ 
            //     g2f o=(g2f)0; 
            //     o.vertex=input[0].vertex; 
            //     o.vertex=input[1].vertex; 
            //     o.vertex=input[2].vertex; 
                 
            //     outStream.Append(o); 
            // } 

            fixed4 frag (g2f i) : SV_Target
            {
                fixed4 finalCol = tex2D(_MainTex, i.uv);
                return finalCol;
            }
            ENDCG
        }
    }
}
